// pages/help/help.js
import {Request} from '../../utils/request.js';
import mock from '../../utils/mock.js';
const app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {

    list: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.loadHelpIssus();
  },


  onShowdoc: function(e) {
    var that = this;
    var list = that.data.list;
    var i = e.currentTarget.dataset.i;
    var j = e.currentTarget.dataset.j;

    list[i].doc[j].isSelected = !list[i].doc[j].isSelected;
    that.setData({
      list: list
    });


  },


  loadHelpIssus: function() {
    let that = this;
    let list = mock.help.list;

    let realList = [];

    for(var i in list){
      list[i].filter(function(j) {
        return j.isSelected = false
      });

      if(i == 'joiner') {
        realList.unshift({'type': '参与者', doc: list[i]});
      }else if(i == 'sponsor') {
        realList.unshift({'type': '发起者', doc: list[i]});
      }
    
    }
    that.setData({
      list: realList
    })
    
  },

  onToggle:function(e) {
    // console.log(e);
  },

 
  onReady: function () {},
  onShow: function () {},
  onHide: function () {},
  onUnload: function () {},
  onPullDownRefresh: function () {},
  onReachBottom: function () {},
})